﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Business.Compta
{
    public class Account
    {
        private int id;
        private List<User> owners;
        private String accountNumber, _accountNumber;
        private String bank, _bank;
        private Double sold, _sold;

        public int Id
        {
            get
            {
                return id;
            }
            set
            {
                this.id = value;
            }
        }

        public List<User> Owners
        {
            get
            {
                return owners;
            }
        }

        public String AccountNumber
        {
            get
            {
                return accountNumber;
            }
            set
            {
                this.accountNumber = value;
            }
        }

        public Double Sold
        {
            get
            {
                return sold;
            }
            set
            {
                this.sold = value;
            }
        }

        public String Bank
        {
            get
            {
                return bank;
            }
            set
            {
                this.bank = value;
            }
        }

        public Account(int _id, String _accountNumber, String _bank, Double _sold, List<User> _owners)
        {
            this.id = _id;
            this.owners = _owners;
            this.accountNumber = _accountNumber;
            this._accountNumber = _accountNumber;
            this.sold = _sold;
            this._sold = _sold;
            this.bank = _bank;
            this._bank = _bank;
        }

        public Account()
        {
            this.id = -1;
        }

        public void commit()
        {
            this._accountNumber = this.accountNumber;
            this._bank = this.bank;
            this._sold = this.sold;
        }

        public void reject()
        {
            this.accountNumber = this._accountNumber;
            this.bank = _bank;
            this.sold = this._sold;
        }

        public Account(int _id, String _accountName, String _bank, Double _sold)
            : this(_id, _accountName, _bank, _sold, new List<User>())
        {
        }

        public void addOwner(User user)
        {
            this.owners.Add(user);
        }

        public void addOwner(int _idUser, String _login, String _userName, String _password, String _lastName, String _mail)
        {
            addOwner(new User(_idUser, _login, _userName, _password, _mail));
        }
    }

}
